//
//  PKGroupImageTableViewCell.m
//  PianKe
//
//  Created by mingtao on 15/10/13.
//  Copyright (c) 2015年 mingtao. All rights reserved.
//

#import "PKGroupImageTableViewCell.h"

@implementation PKGroupImageTableViewCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{

    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _labletitle = [[UILabel alloc]initWithFrame:CGRectMake(10, 15, WIHES, 40)];
        
        
        _labletitle.font = [UIFont systemFontOfSize:20];
        
        [self.contentView addSubview:_labletitle];
        
//        _imageviewcoverimg = [[UIImageView alloc]init];
//        
//        [self.contentView addSubview:_imageviewcoverimg];
        
        _lablecontent=[[UILabel alloc]init];
        
        _lablecontent.frame=CGRectMake(10, 50, WIHES, 100);
       // _lablecontent.backgroundColor = [UIColor greenColor];
        _lablecontent.numberOfLines=0;
        
        [self.contentView addSubview:_lablecontent];
        
        _lableaddtime_f=[[UILabel alloc]init];//initWithFrame:CGRectMake(10, 200, 80, 30)
        
        _lableaddtime_f.font = [UIFont systemFontOfSize:12];
        
        [self.contentView addSubview:_lableaddtime_f];
        
        _imageioc = [[UIImageView alloc]init];
        
       // _imageioc.frame = CGRectMake(300, 120, 30, 30);
        
        [self.contentView addSubview:_imageioc];
        
        _lablecomment=[[UILabel alloc]init];//initWithFrame:CGRectMake(340, 120, 35, 30)
        
        _lablecomment.font = [UIFont systemFontOfSize:12];
        
        [self.contentView addSubview:_lablecomment];
    }
    
    return self;



}

-(void)setGroupModel1:(PKGrouplistModel *)GroupModel1
{

    _GroupModel1 = GroupModel1;

    _labletitle.text = GroupModel1.title;
    

    _lablecontent.text = GroupModel1.content;
    _lablecontent.frame = CGRectMake(10, 50, WIHES-10, [PKGroupImageTableViewCell heightofString1:GroupModel1.content]);
    CGFloat yheig=[PKGroupImageTableViewCell heightofString1:GroupModel1.content];
    _imageioc.image = [UIImage imageNamed:@"iconfont-liaotian"];
    _imageioc.frame = CGRectMake(300, yheig+60, 30, 30);
    _lableaddtime_f.text =GroupModel1.addtime_f;
    _lableaddtime_f.frame = CGRectMake(10, yheig+60, 80, 30);
    
    _lablecomment.text = [NSString stringWithFormat:@"%lu",GroupModel1.counterList.comment];
    
    _lablecomment.frame = CGRectMake(340, yheig+60, 35, 30);

}



//自适应高度
+(CGFloat)heightofString1:(NSString *)introduce
{
    //    NSDictionary *dict=[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:23] forKey:NSFontAttributeName];
    //
    //    CGRect bounds = [str boundingRectWithSize:CGSizeMake(300, 0) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dict context:nil];
    NSDictionary *dict =[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName];
    
    CGRect bounds=[introduce boundingRectWithSize:CGSizeMake(WIHES, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil];
    
    return bounds.size.height;
    
    
}


+(CGFloat)heigHtforContact1:(PKGrouplistModel *)contact1
{
    
    CGFloat heiht =150 +[self heightofString1:contact1.content];
    if (heiht>=150) {
        return heiht;
    }else
    {
        return 150;
    }
    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
